<?php

    class MikronFormFieldDescription
    {
        private $name;
        private $hidden;
        private $id;
        private $form;
        /**
        * @param string $name Field name
        */
        public function __construct(&$form, $name, $hidden)
        {
            $this->form = $form;
            $this->name = $name;
            $this->hidden = $hidden;
            $this->id = 'id'.md5(time().$name.mt_rand(0, 9999999));
        }
        public function getName()
        {
            return $this->name;
        }
        public function getID()
        {
            return $this->id;
        }
        public function isHidden()
        {
            return $this->hidden;
        }
        public function addAjaxFillFromFile($sourceFieldName, $sourceFileAddress)
        {
            echo '=', $this->form->key, '=';
        }
    }
  
  class MikronFormDescription
  {
      private $fields = Array();
      public $key;
      public function __construct($key = null)
      {
          $this->key = $key;
      }
      public function &getField($name)
      {
          if(!array_key_exists($name, $this->fields))
          {
              throw new Exception(sprintf('Форма НЕ содержит поля с именем %s', $name));
          }
          return $this->fields[$name];
      }

      public function &addField($name, $hidden = false)
      {
          if(array_key_exists($name, $this->fields))
          {
              throw new Exception(sprintf('Форма уже содержит поле с именем %s', $name));
          }
          $this->fields[$name] = new MikronFormFieldDescription($this, $name, $hidden);
          return $this->fields[$name];
      }
  }
?>